<template>
  <div class="radio-message">
    <scroll class="radioMes-scroll">
      <!-- 基本介绍 -->
      <div class="base-info">
        <div class="left">
          <img :src="baseInfo.picUrl"
               alt="">
        </div>
        <div class="right">
          <span class="img"></span>
          <span class="name">{{baseInfo.name}}</span>
          <div class="dj">
            <img :src="baseInfo.pic"
                 alt="">
            <span>{{baseInfo.nickname}}</span>
          </div>
          <div class="dr">
            <span class="drs">订阅 ({{baseInfo.subCount}})</span>
            <span class="allplay"
                  @click="PlayMusic()"> <i></i>全部播放</span>
          </div>
          <div class="bottom"
               :class="{fold:fold}">
            <span class="type">{{baseInfo.category}}</span>
            <span class="desc">{{baseInfo.desc}}</span>
            <div class="toggle-fold"
                 @click="fold=!fold">
              <span class="zk"
                    v-if="fold">展开 <i></i></span>
              <span class="sq"
                    v-if="!fold">收起<i></i></span>
            </div>
          </div>

        </div>
      </div>
      <!-- 节目列表 -->
      <div class="list"
           v-if="baseInfo.programCount!=0">
        <p class="list-title">节目列表 <span>共{{baseInfo.programCount}}期</span></p>
        <table cellspacing='0'>
          <tr v-for="(item,index) in musiclist"
              :key="index"
              :class="{backColor:setBackColor(index)}"
              @dblclick="PlayMusic(index)">
            <td>
              {{setSerial(index)}}
              <i v-if="playIndex==index"
                 class="isshow"></i>
              <i v-else></i>
            </td>
            <td>{{item.name}}</td>
            <td class="play">播放{{item.listenerCount}}</td>
            <td class="zan">赞{{item.likedCount}}</td>
            <td class="time">{{item.time}}</td>
          </tr>
        </table>
      </div>
    </scroll>
  </div>
</template>

<script>
import Scroll from 'components/common/scroll/Scroll.vue'
import { _getRadioMes, _getProgress, ProgressMain, RadioMain } from 'network/radio';
import { tableMixin } from 'mixin/tableMixin';
import { indexMixin } from 'mixin/indexMixin';
import { playMixin } from 'mixin/playMixin';
export default {
  components: { Scroll },
  name: 'RadioInfo',
  data () {
    return {
      id: 0,
      baseInfo: {},
      // 节目列表
      musiclist: [],
      fold: true
    }
  },
  mixins: [tableMixin, indexMixin, playMixin],
  created () {
    this.id = this.$route.params.id;
    _getRadioMes(this.id).then(res => {
      const base = new RadioMain(res.data.data);
      this.baseInfo = base;
    })
    _getProgress(this.id).then(res => {
      for (var i of res.data.programs) {
        const progress = new ProgressMain(i);
        this.musiclist.push(progress);
      }
    })
  }
}
</script>

<style scoped>
.radio-message {
  width: 100%;
  box-sizing: border-box;
  height: 100%;
  color: #000;
  padding: 40px;
}
.radioMes-scroll {
  height: 100%;
  overflow: hidden;
}
.base-info {
  width: 100%;
  display: flex;
}
.left {
  width: 233px;
}
.left img {
  width: 200px;
  height: 200px;
}
.right {
  flex: 1;
}
.right .img {
  display: inline-block;
  width: 54px;
  height: 24px;
  background: url("../../../assets/img/newest/icon.png") no-repeat;
  background-position: 0 -186px;
}
.right .name {
  padding-left: 10px;
  vertical-align: 4px;
  font-size: 22px;
}
.right .dj {
  font-size: 13px;
  padding: 5px 0 10px 0;
}
.right .dj img {
  width: 30px;
  height: 30px;
}
.right .dj span {
  vertical-align: 8px;
  padding-left: 10px;
}
.dr span {
  display: inline-block;
  width: 100px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  border: 1px solid rgb(136, 136, 136);
  background: #f7f7f7;
  border-radius: 3px;
  margin-right: 10px;
  font-size: 13px;
  color: #333;
}
.right .drs {
  color: #fff;
  border: none;
  background: #00aa85;
}
.allplay {
  position: relative;
}
.dr .allplay i {
  display: inline-block;
  width: 17px;
  height: 17px;
  vertical-align: -4px;
  background: url("../../../assets/img/newest/table.png") no-repeat 0 9999px;
  background-position: 0 -103px;
  position: absolute;
  left: 2px;
  top: 5px;
}
.bottom {
  margin-top: 20px;
  padding: 10px 0;
  font-size: 15px;
  overflow: hidden;
  width: 100%;
  position: relative;
}
.bottom .type {
  border: 1px solid #00aa85;
  color: #00aa85;
  padding: 3px;
  margin-right: 5px;
}
.list {
  margin-top: 40px;
  width: 100%;
}
.list-title {
  font-size: 20px;
  border-bottom: 2px solid #00aa85;
}
.list-title span {
  font-size: 12px;
  margin-left: 15px;
  color: #333;
}
.list table {
  width: 100%;
  font-size: 13px;
  color: #333;
  border: 1px solid #ddd;
  border-top: none;
}
table tr {
  height: 40px;
}
table tr td:nth-child(1) {
  width: 100px;
  text-align: left;
  padding: 0 10px;
  color: #999999;
}
table tr td {
  position: relative;
}
table tr td .isshow {
  background-position: -20px -128px;
}
table tr td i {
  display: inline-block;
  width: 17px;
  height: 17px;
  vertical-align: -4px;
  background: url("../../../assets/img/newest/table.png") no-repeat 0 9999px;
  background-position: 0 -103px;
  position: absolute;
  right: 30px;
  top: 12px;
}
.zan {
  width: 15%;
}
.time {
  width: 15%;
}
.play {
  width: 20%;
}
.backColor {
  background: #f7f7f7 !important;
}
/* 折叠 */
.fold {
  height: 50px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.toggle-fold {
  position: absolute;
  bottom: 0px;
  right: 10px;
  color: #00aa85;
}
</style>
